<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    
    
    <xsl:attribute-set name="all-borders">
        <xsl:attribute name="border-top-style">solid</xsl:attribute>
        <xsl:attribute name="border-top-width">0.2mm</xsl:attribute>
        <xsl:attribute name="border-right-style">solid</xsl:attribute>
        <xsl:attribute name="border-right-width">0.2mm</xsl:attribute>
        <xsl:attribute name="border-left-style">solid</xsl:attribute>
        <xsl:attribute name="border-left-width">0.2mm</xsl:attribute>
        <xsl:attribute name="border-bottom-style">solid</xsl:attribute>
        <xsl:attribute name="border-bottom-width">0.2mm</xsl:attribute>
        <xsl:attribute name="text-align">center</xsl:attribute>
        <xsl:attribute name="font-family">Calibri</xsl:attribute>
    </xsl:attribute-set>

    <xsl:template match="/Baza">
        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
            <fo:layout-master-set>
                <fo:simple-page-master master-name="page" page-height="21cm" page-width="29.7cm" margin-top="1cm" margin-bottom="2cm" margin-left="0.5cm" margin-right="0.5cm">
                    <fo:region-body margin-top="4cm"/>
                    <fo:region-before extent="1cm"/>
                    <fo:region-after extent="1.5cm"/>
                </fo:simple-page-master>
                
                <fo:page-sequence-master master-name="all">
                    <fo:repeatable-page-master-alternatives>
                        <fo:conditional-page-master-reference master-reference="page" page-position="first"/>
                    </fo:repeatable-page-master-alternatives>
                </fo:page-sequence-master>
            </fo:layout-master-set>
            
            <xsl:apply-templates/>
        </fo:root>
    </xsl:template>
    
    
    <xsl:template match="/Baza/Pojazdy">
        <fo:page-sequence master-reference="all">
            <fo:flow flow-name="xsl-region-body">
                
                    <fo:table xsl:use-attribute-sets="all-borders">
                        <fo:table-column column-width="10mm"/>
                        <fo:table-column column-width="25mm"/>
                        <fo:table-column column-width="20mm"/>
                        <fo:table-column column-width="12mm"/>
                        <fo:table-column column-width="35mm"/>
                        <fo:table-column column-width="30mm"/>
                        <fo:table-column column-width="50mm"/>
                        <fo:table-column column-width="100mm"/>
                        
                        <fo:table-header>
                            <fo:table-row>
                                <fo:table-cell xsl:use-attribute-sets="all-borders" number-columns-spanned="8" background-color="#27B633" text-align="center"><fo:block font-weight="bold" color="#B9F0BE" padding="1mm"><xsl:text>BAZA DANYCH WARZTATU SAMOCHODOWEGO</xsl:text></fo:block></fo:table-cell>
                            </fo:table-row>
                            <fo:table-row background-color="#66DE70" color="#15621B">
                                <fo:table-cell xsl:use-attribute-sets="all-borders"><fo:block font-weight="bold">ID</fo:block></fo:table-cell>
                                <fo:table-cell xsl:use-attribute-sets="all-borders"><fo:block font-weight="bold">MARKA</fo:block></fo:table-cell>
                                <fo:table-cell xsl:use-attribute-sets="all-borders"><fo:block font-weight="bold">MODEL</fo:block></fo:table-cell>
                                <fo:table-cell xsl:use-attribute-sets="all-borders"><fo:block font-weight="bold">ROK</fo:block></fo:table-cell>
                                <fo:table-cell xsl:use-attribute-sets="all-borders"><fo:block font-weight="bold">WŁAŚCICIEL</fo:block></fo:table-cell>
                                <fo:table-cell xsl:use-attribute-sets="all-borders"><fo:block font-weight="bold">NASTĘPNY PRZEGLĄD</fo:block></fo:table-cell>
                                <fo:table-cell xsl:use-attribute-sets="all-borders"><fo:block font-weight="bold">NAPRAWY</fo:block></fo:table-cell>
                                <fo:table-cell xsl:use-attribute-sets="all-borders"><fo:block font-weight="bold">CZĘŚCI</fo:block></fo:table-cell>
                            </fo:table-row>
                        </fo:table-header>
                        
                        <fo:table-body>
                            <xsl:for-each select="Samochód">
                                <fo:table-row background-color="#B9F0BE" >
                                    <fo:table-cell xsl:use-attribute-sets="all-borders" background-color="#66DE70" color="#15621B">
                                        <fo:block font-weight="bold" font-size="9pt">
                                            <xsl:value-of select="@id"/>
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell xsl:use-attribute-sets="all-borders">
                                        <fo:block font-size="9pt" font-style="italic">
                                        <xsl:value-of select="marka"/>
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell xsl:use-attribute-sets="all-borders">
                                        <fo:block font-size="9pt" font-style="italic">
                                            <xsl:value-of select="model"/>
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell xsl:use-attribute-sets="all-borders">
                                        <fo:block font-size="9pt">
                                            <xsl:value-of select="rok_produkcji"/>
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell xsl:use-attribute-sets="all-borders">
                                        <fo:block  font-size="9pt">
                                            <xsl:value-of select="Właściciel"/>
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell xsl:use-attribute-sets="all-borders">
                                        <fo:block  font-size="9pt">
                                            <xsl:value-of select="Przegląd_do"/>
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell xsl:use-attribute-sets="all-borders">
                                        <fo:block font-size="9pt">
                                            <xsl:value-of select="Naprawy"/>
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell xsl:use-attribute-sets="all-borders">
                                        <fo:block font-size="9pt">
                                            <xsl:value-of select="Części"/>
                                        </fo:block>
                                    </fo:table-cell>
                                </fo:table-row>
                                
                            </xsl:for-each>
                            
                        </fo:table-body>
                    </fo:table>
                
            </fo:flow>
        </fo:page-sequence>
    </xsl:template>
    
    <xsl:template match="/Baza/Koszty">
        <fo:page-sequence master-reference="all">
            <fo:flow flow-name="xsl-region-body">
                
                <fo:table xsl:use-attribute-sets="all-borders">
                    <fo:table-column column-width="10mm"/>
                    <fo:table-column column-width="25mm"/>
                    <fo:table-column column-width="28mm"/>
                    <fo:table-column column-width="25mm"/>
                    <fo:table-column column-width="25mm"/>
                    <fo:table-column column-width="30mm"/>
                    <fo:table-column column-width="20mm"/>
                    
                    <fo:table-header>
                        <fo:table-row>
                            <fo:table-cell xsl:use-attribute-sets="all-borders" number-columns-spanned="7" background-color="#12697F" text-align="center"><fo:block font-weight="bold" color="#CCEFF7" padding="1mm"><xsl:text>BAZA DANYCH WARZTATU SAMOCHODOWEGO</xsl:text></fo:block></fo:table-cell>
                        </fo:table-row>
                        <fo:table-row background-color="#20B4D8" color="#106880">
                            <fo:table-cell xsl:use-attribute-sets="all-borders"><fo:block font-weight="bold">ID</fo:block></fo:table-cell>
                            <fo:table-cell xsl:use-attribute-sets="all-borders"><fo:block font-weight="bold">IMIĘ I NAZWISKO</fo:block></fo:table-cell>
                            <fo:table-cell xsl:use-attribute-sets="all-borders"><fo:block font-weight="bold">SAMOCHODY</fo:block></fo:table-cell>
                            <fo:table-cell xsl:use-attribute-sets="all-borders"><fo:block font-weight="bold">KOSZTY NAPRAW</fo:block></fo:table-cell>
                            <fo:table-cell xsl:use-attribute-sets="all-borders"><fo:block font-weight="bold">KOSZTY CZĘŚCI</fo:block></fo:table-cell>
                            <fo:table-cell xsl:use-attribute-sets="all-borders"><fo:block font-weight="bold">KOSZTY PRZEGLĄDÓW</fo:block></fo:table-cell>
                            <fo:table-cell xsl:use-attribute-sets="all-borders"><fo:block font-weight="bold">SUMA</fo:block></fo:table-cell>
                        </fo:table-row>
                    </fo:table-header>
                    
                    <fo:table-body>
                        <xsl:for-each select="Właściciel">
                            <fo:table-row background-color="#73D3EA" color="#051F26">
                                <fo:table-cell xsl:use-attribute-sets="all-borders" background-color="#20B4D8" color="#106880">
                                    <fo:block font-weight="bold" font-size="9pt">
                                        <xsl:value-of select="@wł_id"/>
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell xsl:use-attribute-sets="all-borders">
                                    <fo:block font-size="9pt" font-style="italic">
                                        <xsl:value-of select="imię_i_nazwisko"/>
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell xsl:use-attribute-sets="all-borders">
                                    <fo:block font-size="9pt" font-style="italic">
                                        <xsl:value-of select="translate(Pojazd,';', '')"/>
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell xsl:use-attribute-sets="all-borders">
                                    <fo:block font-size="9pt">
                                        <xsl:value-of select="concat(Koszt_napraw, ' zł')"/>
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell xsl:use-attribute-sets="all-borders">
                                    <fo:block  font-size="9pt">
                                        <xsl:value-of select="concat(Koszt_części, ' zł')"/>
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell xsl:use-attribute-sets="all-borders">
                                    <fo:block  font-size="9pt">
                                        <xsl:value-of select="concat(Koszt_przeglądów, ' zł')"/>
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell xsl:use-attribute-sets="all-borders">
                                    <fo:block font-size="9pt">
                                        <xsl:value-of select="concat(Suma, ' zł')"/>
                                    </fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                            
                        </xsl:for-each>
                        
                    </fo:table-body>
                </fo:table>
                
            </fo:flow>
        </fo:page-sequence>
    </xsl:template>
    
    <xsl:template match="/Baza/Podsumowanie">
        <fo:page-sequence master-reference="all">
            <fo:flow flow-name="xsl-region-body">
                <fo:list-block font-family="Mistral" font-size="30">
                    <xsl:for-each select="Autorzy/Autor">
                        <fo:list-item>
                          <fo:list-item-label>
                              <fo:block>AUTOR: </fo:block>
                          </fo:list-item-label>
                          <fo:list-item-body>
                              <fo:block margin-left="1.8cm"><xsl:value-of select="."/></fo:block>
                          </fo:list-item-body>
                       </fo:list-item>
                    </xsl:for-each>
                    <fo:list-item>
                        <fo:list-item-label>
                            <fo:block>DATA UTWORZENIA: </fo:block>
                        </fo:list-item-label>
                        <fo:list-item-body>
                            <fo:block margin-left="4.5cm"><xsl:value-of select="substring(translate(Data_utworzenia,'T',' '),1,19)"/></fo:block></fo:list-item-body>
                    </fo:list-item>
                </fo:list-block>
            </fo:flow>
        </fo:page-sequence>
    </xsl:template>
    
</xsl:stylesheet>